package com.lb.jwitter.action.assessment;


import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;

import com.lb.jwitter.Tbl_TaiKhoan;
import com.lb.jwitter.hibernate.CommonDAO;
import com.lb.utils.orm.hibernate.Message;
import com.opensymphony.xwork2.Action;


@ContextConfiguration(locations="classpath:beans.xml")
public class AssessmentSubjectSearchAction
{

	private List<Map<String, Object>> listSubject;
	
	public List<Map<String, Object>> getListSubject() {
		return listSubject;
	}

	public void setListSubject(List<Map<String, Object>> listSubject) {
		this.listSubject = listSubject;
	}

	///////////////////////////////////
	private Message msg;
	
	public Message getMsg() {
		return msg;
	}

	public void setMsg(Message msg) {
		this.msg = msg;
	}
	
	private String programId;
	public String getProgramId() {
		return programId;
	}

	public void setProgramId(String programId) {
		this.programId = programId;
	}
	/////////////////////////////////////
	private Tbl_TaiKhoan taiKhoanDangNhap;


	public Tbl_TaiKhoan getTaiKhoanDangNhap() {
		return taiKhoanDangNhap;
	}

	public void setTaiKhoanDangNhap(Tbl_TaiKhoan taiKhoanDangNhap) {
		this.taiKhoanDangNhap = taiKhoanDangNhap;
	}

	////////////////////////////////////


	@Autowired
	@Qualifier("commonDAO")
	private CommonDAO commonDao;
	
	public String execute() throws Exception
	{
		msg = new Message();
		try {

			String query="SELECT subject.idSubject, subject.Name " +
   					"FROM 	subject " +
   					"INNER JOIN	studysemester " +
   					"ON (subject.idSubject = studysemester.idSubject) " +
   					"WHERE studysemester.Program = '" + programId + "'";

			listSubject = commonDao.query_SQL_WithParams_AliasTransformer(
					query, null, 0, 0);

			return Action.SUCCESS;

	    }
		catch(Exception e){
        	e.printStackTrace();
            msg.setPreMessage_b(false);
            msg.setPreMessage_s("Error ");
            return Action.ERROR;
		}
	}	
}
